﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UnReliefAbnormalMasterForm.aspx.cs"
    Inherits="FX.CC.Andon.WebSite.DataManage.UnReliefAbnormalMasterForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="../lib/boot.js" type="text/javascript"></script>
</head>
<body>
    <div class="mini-toolbar" style="padding: 2px; border-bottom: 0;">
        <table>
            <tr>
                <td  align="right">
                    开始日期：
                </td>
                <td style="width: 150px;" align="left">
                    <input id="BizDateFrom" style="width: 150px;" class="mini-datepicker" format="yyyy-MM-dd" />
                </td>
                <td  align="right">
                    结束日期：
                </td>
                <td style="width: 150px;" align="left">
                    <input id="BizDateEnd" style="width: 150px;" class="mini-datepicker" format="yyyy-MM-dd" />
                </td>
                <td style="width: 100px">
                    <a class="mini-button" iconcls="icon-search" onclick="search()">查 询</a>
                </td>
            </tr>
            <tr>
                <td align="right">
                    产线：
                </td>
                <td style="width: 150px;" align="left">
                    <div id="LineID" name="LineID" class="mini-combobox" style="width: 150px;" popupwidth="300"
                        textfield="LineName" valuefield="LineID" url="../Service/BasicDataManageHandler.ashx?action=GetLineListByCombobox">
                        <div property="columns">
                            <div header="产线编号" field="LineCode">
                            </div>
                            <div header="产线名称" field="LineName">
                            </div>
                        </div>
                    </div>
                </td>
                <td align="right">
                    设备编号：
                </td>
                <td style="width: 150px;" align="left">
                    <input name="EqCode" id="EqCode" emptytext="请输入设备编号" style="width: 150px;" class="mini-textbox" />
                </td>
                <td style="width: 100px">
                    <a class="mini-button" iconcls="icon-reset" onclick="reset()">重 置</a>
                </td>
            </tr>
        </table>
    </div>
    <div class="mini-toolbar" style="padding: 2px; border-bottom: 0;">
        <table style="width: 100%;">
            <tr>
                <td style="width: 100%;">
                    <a class="mini-button" iconcls="icon-edit" onclick="edit()" plain="true">编辑</a>
                    <a class="mini-button" iconcls="icon-remove" onclick="remove()" plain="true">删除</a>
                    <span class="separator"></span><a class="mini-button" onclick="close()" iconcls="icon-close"
                        plain="true">关闭</a>
                </td>
            </tr>
        </table>
    </div>
    <!--撑满页面-->
    <div class="mini-fit">
        <div id="datagrid1" class="mini-datagrid" style="width: 100%; height: 100%;" idfield="EventID"
            sizelist="[10,20,50,100]" pagesize="20">
            <div property="columns">
                <div type="indexcolumn">
                </div>
                <div field="LineName" width="120" headeralign="center" allowsort="true">
                    产线名称
                </div>
                <div field="EqCode" width="110" headeralign="center" allowsort="true">
                    设备编号
                </div>
                <div field="EqName" width="200" headeralign="center" allowsort="true">
                    设备名称
                </div>
                <div field="StartTime" width="130" headeralign="center" allowsort="true" dateformat="yyyy-MM-dd HH:mm:ss">
                    异常触发时间
                </div>
                <div field="ETypeName" width="90" headeralign="center" allowsort="true">
                    异常原因
                </div>
                <div field="DetailCode" width="110" headeralign="center" allowsort="true">
                    异常明细编号
                </div>
                <div field="DetailName" width="200" headeralign="center" allowsort="true">
                    异常明细名称
                </div>
                <div field="StartUserFullName" width="90" headeralign="center" allowsort="true">
                    操作人
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        mini.parse();
        var now = new Date();
        var nowYear = now.getFullYear();
        var nowMonth = now.getMonth();
        var bizDateFrom = mini.get("BizDateFrom");
        bizDateFrom.setValue(new Date(nowYear, nowMonth, 1));
        var bizDateEnd = mini.get("BizDateEnd");
        bizDateEnd.setValue(new Date());
        var grid = mini.get("datagrid1");
        function search() {
            var BizDateFrom = mini.get("BizDateFrom").getFormValue();
            var BizDateEnd = mini.get("BizDateEnd").getFormValue();
            var LineID = mini.get("LineID").getValue();
            var EqCode = mini.get("EqCode").getValue();
            grid.setUrl("../service/DataManageHandler.ashx?action=GetUnReliefAbnormalList");
            grid.load({ BizDateFrom: BizDateFrom, BizDateEnd: BizDateEnd, LineID: LineID, EqCode: EqCode });
        }

        //回车键事件
        function onKeyEnter() {
            search();
        }
        function reset() {
            var now = new Date();
            var nowYear = now.getFullYear();
            var nowMonth = now.getMonth();
            var bizDateFrom = mini.get("BizDateFrom");
            bizDateFrom.setValue(new Date(nowYear, nowMonth, 1));
            var bizDateEnd = mini.get("BizDateEnd");
            bizDateEnd.setValue(new Date());
            mini.get("LineID").setValue("");
        }

        function edit() {
            var rows = grid.getSelected();
            if (rows) {
                mini.open({
                    url: "DataManage/UnReliefAbnormalInfoForm.aspx",
                    title: "编辑", width: 443, height: 415,
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = { action: "edit", EventID: rows.EventID, LineName: rows.LineName, EqCode: rows.EqCode, EqName: rows.EqName, StartTime: rows.StartTime, ETypeName: rows.ETypeName, StartUserID: rows.StartUserID, StartUserFullName: rows.StartUserFullName };
                        iframe.contentWindow.SetData(data);

                    },
                    ondestroy: function (action) {
                        grid.reload();
                    }
                });
            }
            else {
                mini.alert("请选中一条您需要编辑的记录!");
            }
        }

        function remove() {
            var rows = grid.getSelected();
            if (rows) {
                mini.confirm("您确定删除:" + rows.EqCode + "？", "确定？",
                    function (action) {
                        if (action == "ok") {
                            $.ajax({
                                url: "../service/DataManageHandler.ashx?action=RemoveUnReliefAbnormal&EventID=" + rows.EventID,
                                success: function (text) {
                                    grid.reload();
                                },
                                error: function () {
                                }
                            });

                        } else {
                            return false;
                        }
                    });
            } else {
                mini.alert("请选中一条您需要删除的记录!");
            }
        }

        function CloseWindow(action) {
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();
        }

        function close() {
            CloseWindow("close");
        }
    </script>
</body>
</html>
